from lianxi.xiecheng.base import base
from selenium.webdriver.common.by import By
from selenium import webdriver

class oneday_page(base):
    oneday1 = (By.XPATH, '/html/body/div[5]/div[1]/ul/li[5]/a')#悬停
    oneday2 = (By.LINK_TEXT, '旅游首页')#点击旅游首页
    oneday3 = (By.ID, 'online-search-input-box')#输入目的地
    oneday4 = (By.XPATH, '/html/body/div[2]/div/div[1]/div[3]/div/a[5]')#点击一日游
    oneday5 = (By.XPATH, '/html/body/div[2]/section/div/div[3]/div[2]/div[1]/div[2]/div[1]/div[3]/div[2]/div/div[2]/div[1]/a')#点击长城一日游
    oneday6 = (By.XPATH, '/html/body/div[2]/div/div/div/div/div[1]/div[1]/div/div[3]/div[3]/div/div[1]/div/div/div[1]/div/div[2]/table/tbody/tr[3]/td[6]/a/span[2]')#点击17号
    oneday7 = (By.XPATH, '/html/body/div[2]/div/div/div/div/div[1]/div[1]/div/div[3]/div[3]/div/div[2]/div[1]/ul/li[1]/div/div/a[6]')#点击十二点单长城
    oneday8 = (By.XPATH, '/html/body/div[2]/div/div/div/div/div[1]/div[1]/div/div[3]/div[3]/div/div[2]/div[1]/ul/li[2]/div/div/a[7]')#选择套餐
    oneday9 = (By.LINK_TEXT, '立即预订')#点击立即预订
    oneday10 = (By.XPATH, '/html/body/div[2]/div/div/div/div/div[1]/div[1]/div/div[3]/div[3]/div/div[2]/div[1]/ul/li[5]/div/div[2]/div[1]/div[2]/span/a[2]')#人数+1
    oneday11 = (By.XPATH, '/html/body/div[2]/div/div/div/div/div[3]/div[3]/div[2]/ul/li[2]/label/span[1]/span')#勾选出行人1
    oneday12 = (By.XPATH, '/html/body/div[2]/div/div/div/div/div[3]/div[3]/div[2]/ul/li[2]/label/span[1]/span')#勾选出行人2
    oneday14 = (By.XPATH, '/html/body/div[2]/div/div/div/div/div[3]/div[4]/div[2]/div/ul/li/div/div/div/input')#输入上车点
    oneday15 = (By.XPATH, '/html/body/div[2]/div/div/div/div/div[3]/div[9]/div/div/button/span')#点击去支付



    url = 'https://www.ctrip.com/'# 网址
    tx1= '北京'# 目的地
    tx4 = '东四环'# 输入上车点
    def oneday(self):
        self.get_url(self.url)
        self.get_sleep()
        self.add_cookie()
        self.get_sx()
        self.get_sleep()
        self.get_move(*self.oneday1)
        self.get_sleep()
        self.get_click(*self.oneday2)
        self.get_sleep()
        self.get_text(self.tx1,*self.oneday3)
        self.get_sleep()
        self.get_huiche(*self.oneday3)
        self.get_sleep()
        self.get_click(*self.oneday4)
        self.get_sleep()
        self.driver.execute_script("window.scrollTo(0,300)")
        self.get_sleep()
        self.get_click(*self.oneday5)
        self.get_sleep()
        self.get_jb(-1)
        self.driver.execute_script("window.scrollTo(0,300)")
        self.get_sleep()
        self.get_click(*self.oneday6)
        self.get_sleep()
        self.get_click(*self.oneday7)
        self.get_sleep()
        self.get_click(*self.oneday8)
        self.get_sleep()
        self.driver.execute_script("window.scrollTo(0,100)")
        self.get_sleep()
        self.get_click(*self.oneday10)
        self.get_sleep()
        self.get_click(*self.oneday9)
        self.get_sleep()
        self.get_jb(-1)
        self.get_max()
        self.get_click(*self.oneday11)
        self.get_sleep()
        self.get_click(*self.oneday12)
        self.get_sleep()
        self.driver.execute_script("window.scrollTo(0,1500)")
        self.get_sleep()
        self.get_text(self.tx4, *self.oneday14)
        self.get_sleep()
        self.get_click(*self.oneday15)
        self.get_sleep()